package Example.Components;

import org.objectweb.fractal.api.NoSuchInterfaceException;
import org.objectweb.fractal.api.control.BindingController;
import org.objectweb.fractal.api.control.IllegalBindingException;
import org.objectweb.fractal.api.control.IllegalLifeCycleException;

import Example.Interfaces.AccountOprs;
import Example.Interfaces.UQuery;
import Example.Interfaces.USave;

public class User implements AccountOprs, BindingController{


	public double checkBalance(int userID) {
		// TODO Auto-generated method stub
		return 0.0;
	}


	public Object[] checkID(int userID, String userPassword) {
		System.out.println("user");
		return UQuery.findAccount(userID, userPassword);
	}

	public double debit(int userID, double cost) {
		// TODO Auto-generated method stub
		return 0.0;
	}


	public void bindFc(String cItf, Object sItf)
			throws NoSuchInterfaceException, IllegalBindingException,
			IllegalLifeCycleException {
		if(cItf.equals("UQuery"))
			UQuery=(UQuery)sItf;
		if(cItf.equals("USave"))
			USave=(USave)sItf;
		
	}


	public String[] listFc() {
		 return new String[]{"UQuery","USave"};
	}


	public Object lookupFc(String cItf)
			throws NoSuchInterfaceException {
		if(cItf.equals("UQuery"))
			return UQuery;
		if(cItf.equals("USave"))
			return USave;		
		return null;
	}


	public void unbindFc(String cItf) throws NoSuchInterfaceException,
			IllegalBindingException, IllegalLifeCycleException {
		if(cItf.equals("UQuery"))
			UQuery=null;
		if(cItf.equals("USave"))
			USave=null;
		
	}
	private UQuery UQuery;
	private USave USave;

}
